#include <iostream>
#include <cmath>
using namespace std;
int n,k;
const int N=25;
int a[N];
typedef long long LL;
LL sum=0;
LL count=0;
bool judge(int x)
{
	for(int i=2;i<=sqrt(x);i++)
	{
		if(x%i==0)return false;
	}
	return true;
}
void dfs(int pos,int begin)
{
	if(pos>k)
	{
		if(judge(sum))
      count++;
		return;
	}
	for(int i=begin;i<=n;i++)
	{
		sum+=a[i];
		dfs(pos+1,i+1);
		sum-=a[i];
		
	}
}
int main()
{
   cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dfs(1,1);
	cout<<count;
	return 0;
}
